<%@page import="utils.ClassRegistry"%>
<%@page import="ajaxmethods.AjaxMethod"%>

<%
	if (request.getParameter("do") != null)
	{
		try
		{
			Class<AjaxMethod> methodClass = (Class<AjaxMethod>) Class.forName(request.getParameter("do"));
			AjaxMethod method = ClassRegistry.getInstance(methodClass);
			method.perform(request, response);
			response.flushBuffer();
		}
		catch (ClassNotFoundException ex)
		{
			response.getWriter().println();
			throw new ServletException(request.getParameter("do"));
		}
		catch (ClassCastException ex)
		{
			throw new ServletException("Invalid action");
		}
	}
	else
		throw new ServletException("Missing or invalid action");	
%>